home *** CD-ROM | disk | FTP | other *** search
- class MiniGames.PTB.PushTheBusMG extends MiniGames.BaseMiniGame
- {
- var nDone;
- var bModeSandy;
- var nRange;
- var nNumberTimes;
- var nNextDir;
- var mcRef;
- var nPosX;
- var sState;
- var bOver;
- static var sSTATE_SANDY = "Sandy";
- static var sSTATE_BOB = "SpongeBob";
- static var sSTATE_SANDY_WHACKY = "SandyWhacky";
- static var sSTATE_BOB_WHACKY = "BobWhacky";
- static var nDIR_LEFT = 1;
- static var nDIR_RIGHT = 2;
- static var nTIME_TO_PUSH_SANDY = 40;
- static var nTIME_TO_PUSH_BOB = 70;
- static var nMAX_TIME = 16;
- static var nSECOND_VALUE = 100;
- static var nRANGE_SANDY = 40;
- static var nRANGE_BOB = 40;
- function PushTheBusMG(_mcRef)
- {
- super(_mcRef);
- this.nDone = 0;
- if(CTRLGame.getRef().Level == CTRLGame.nLEVEL1)
- {
- this.bModeSandy = true;
- this.nRange = MiniGames.PTB.PushTheBusMG.nRANGE_SANDY;
- this.nNumberTimes = MiniGames.PTB.PushTheBusMG.nTIME_TO_PUSH_SANDY;
- }
- else
- {
- this.bModeSandy = false;
- this.nRange = MiniGames.PTB.PushTheBusMG.nRANGE_BOB;
- this.nNumberTimes = MiniGames.PTB.PushTheBusMG.nTIME_TO_PUSH_BOB;
- }
- this.nNextDir = MiniGames.PTB.PushTheBusMG.nDIR_LEFT;
- this.showInstructions();
- }
- function initMiniGame()
- {
- this.mcRef.mcState.mcMode.mcBus.mcStrenght.gotoAndStop(this.mcRef.mcState.mcStrenght._totalframes);
- this.nPosX = 300;
- }
- function calculateScore()
- {
- this.addScoreFromTimeLeft(MiniGames.PTB.PushTheBusMG.nMAX_TIME,MiniGames.PTB.PushTheBusMG.nSECOND_VALUE);
- }
- function validateEndMiniGame()
- {
- if(this.nDone >= this.nNumberTimes)
- {
- this.setVictory();
- }
- }
- function setState(_sState)
- {
- super.setState(_sState);
- this.setPlayCharacter();
- }
- function doPause()
- {
- super.doPause();
- if(this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME)
- {
- this.mcRef.mcState.mcBus.stop();
- }
- else if(this.sState == MiniGames.BaseMiniGame.sSTATE_VICTORY)
- {
- this.mcRef.mcState.mcMode.stop();
- this.mcRef.mcState.mcMode.mcBus.stop();
- }
- }
- function doUnPause()
- {
- super.doUnPause();
- this.mcRef.mcState.stop();
- if(this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME)
- {
- this.mcRef.mcState.mcBus.play();
- }
- else if(this.sState == MiniGames.BaseMiniGame.sSTATE_VICTORY)
- {
- this.mcRef.mcState.mcMode.play();
- this.mcRef.mcState.mcMode.mcBus.play();
- }
- }
- function setPlayCharacter()
- {
- if(this.bModeSandy)
- {
- if(Main.getRef().isCheatClothesActivated())
- {
- this.mcRef.mcState.gotoAndStop(MiniGames.PTB.PushTheBusMG.sSTATE_SANDY_WHACKY);
- }
- else
- {
- this.mcRef.mcState.gotoAndStop(MiniGames.PTB.PushTheBusMG.sSTATE_SANDY);
- }
- }
- else if(Main.getRef().isCheatClothesActivated())
- {
- this.mcRef.mcState.gotoAndStop(MiniGames.PTB.PushTheBusMG.sSTATE_BOB_WHACKY);
- }
- else
- {
- this.mcRef.mcState.gotoAndStop(MiniGames.PTB.PushTheBusMG.sSTATE_BOB);
- }
- var _loc2_ = this.mcRef.mcState.mcMode.mcBus.mcStrenght._totalframes / this.nNumberTimes * this.nDone;
- this.mcRef.mcState.mcMode.mcBus.mcStrenght.gotoAndStop(100 - Math.round(_loc2_));
- }
- function onKeyPressed()
- {
- this.nDone = this.nDone + 1;
- var _loc2_ = this.mcRef.mcState.mcMode.mcBus.mcStrenght._totalframes / this.nNumberTimes * this.nDone;
- this.mcRef.mcState.mcMode.mcBus.mcStrenght.gotoAndStop(100 - Math.round(_loc2_));
- }
- function validateActions()
- {
- if(!Controller.getRef().isPaused())
- {
- if(this.nNextDir == MiniGames.PTB.PushTheBusMG.nDIR_LEFT)
- {
- if(CTRLGame.getRef().mcRef._xmouse <= this.nPosX - this.nRange)
- {
- this.onKeyPressed();
- this.nNextDir = MiniGames.PTB.PushTheBusMG.nDIR_RIGHT;
- }
- }
- else if(this.nNextDir == MiniGames.PTB.PushTheBusMG.nDIR_RIGHT)
- {
- if(CTRLGame.getRef().mcRef._xmouse >= this.nPosX + this.nRange)
- {
- this.nNextDir = MiniGames.PTB.PushTheBusMG.nDIR_LEFT;
- this.onKeyPressed();
- }
- }
- }
- }
- function setVictory()
- {
- this.setState(MiniGames.BaseMiniGame.sSTATE_VICTORY);
- CTRLGame.getRef().Screen.getInterface().pauseTime();
- this.mcRef.mcState.mcMode.mcBus.mcStrenght.stop();
- Controller.getRef().getSounds().playSound("alguaetore",Controller.nSFX_VOLUME,1);
- }
- function HowToPlayIn()
- {
- if(this.mcRef.mcState.mcMode._currentframe == this.mcRef.mcState.mcMode._totalframes)
- {
- this.setState(MiniGames.BaseMiniGame.sSTATE_HOWTOPLAY_IDLE);
- this.initSkipKeys();
- }
- }
- function HowToPlayIdle()
- {
- if(this.mcRef.mcState.mcMode._currentframe == this.mcRef.mcState.mcMode._totalframes)
- {
- this.setState(MiniGames.BaseMiniGame.sSTATE_HOWTOPLAY_OUT);
- }
- }
- function HowToPlayOut()
- {
- if(this.mcRef.mcState.mcMode._currentframe == this.mcRef.mcState.mcMode._totalframes)
- {
- this.startGame();
- }
- }
- function MiniGame()
- {
- super.MiniGame();
- this.validateActions();
- }
- function Victory()
- {
- if(this.mcRef.mcState.mcMode._currentframe == this.mcRef.mcState.mcMode._totalframes - 15)
- {
- this.bOver = true;
- }
- }
- }
-